<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>智慧绘画 - 深绘智创</title>
    <link rel="stylesheet" href="{{ url_for('static', filename='css/main.css') }}">
    <link rel="stylesheet" href="{{ url_for('static', filename='css/chat.css') }}">
    <link rel="stylesheet" href="{{ url_for('static', filename='css/prompt-fix.css') }}">
    <link rel="stylesheet" href="{{ url_for('static', filename='css/draw.css') }}">
    <link rel="icon" href="{{ url_for('static', filename='img/favicon.svg') }}" type="image/svg+xml">
    <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
    <style>
        .image-grid {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 12px;
            margin-top: 15px;
        }
        
        .grid-4 {
            grid-template-columns: 1fr 1fr;
        }
        
        .image-item {
            position: relative;
            aspect-ratio: 1;
            overflow: hidden;
            border-radius: 8px;
            background-color: #f0f0f0;
            cursor: pointer;
            transition: transform 0.2s;
        }
        
        .image-item:hover {
            transform: scale(1.02);
        }
        
        .image-item img {
            width: 100%;
            height: 100%;
            object-fit: cover;
        }
        
        .image-placeholder {
            display: flex;
            align-items: center;
            justify-content: center;
            width: 100%;
            height: 100%;
            background-color: #f0f0f0;
        }
        
        .params-summary {
            background-color: rgba(0, 0, 0, 0.02);
            border-radius: 8px;
            padding: 10px 15px;
            margin-top: 10px;
            font-size: 0.9em;
        }
        
        .params-summary h4 {
            margin: 0 0 8px 0;
            font-size: 1em;
            color: #555;
        }
        
        .params-summary ul {
            margin: 0;
            padding-left: 20px;
        }
        
        /* 绘画特有样式 */
        .drawing-tips {
            margin: 20px auto;
            max-width: 600px;
            padding: 15px;
            background-color: #f5f9ff;
            border-radius: 8px;
            border-left: 4px solid #4c84ff;
        }
        
        .drawing-tips h3 {
            margin-top: 0;
            color: #4c84ff;
        }
        
        .drawing-tags {
            display: flex;
            flex-wrap: wrap;
            gap: 8px;
            margin-bottom: 15px;
        }
        
        .drawing-tag {
            padding: 5px 10px;
            background-color: #e0e9ff;
            color: #4c84ff;
            border-radius: 20px;
            cursor: pointer;
            font-size: 0.9em;
        }
        
        .drawing-tag:hover {
            background-color: #d0dfff;
        }
        
        .advanced-options {
            margin-top: 15px;
        }
        
        .advanced-toggle {
            color: #4c84ff;
            cursor: pointer;
            user-select: none;
            display: flex;
            align-items: center;
        }
        
        .advanced-params {
            display: none;
            margin-top: 10px;
        }
        
        .advanced-params.visible {
            display: block;
        }
        
        .param-row {
            display: flex;
            align-items: center;
            margin-bottom: 8px;
            gap: 10px;
        }
        
        .param-row label {
            width: 120px;
            font-size: 0.9em;
        }
        
        .param-row input,
        .param-row select {
            flex: 1;
            padding: 5px 8px;
            border: 1px solid #ddd;
            border-radius: 4px;
        }
        
        .param-row input[type="range"] {
            margin: 0;
        }
        
        .welcome-screen.drawing-welcome {
            text-align: center;
        }
        
        .welcome-screen.drawing-welcome h2 {
            color: #4c84ff;
            margin-bottom: 20px;
        }
        
        .example-images {
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: 15px;
            margin: 25px 0;
        }
        
        .example-image {
            border-radius: 8px;
            overflow: hidden;
            cursor: pointer;
            transition: transform 0.2s;
        }
        
        .example-image:hover {
            transform: scale(1.05);
        }
        
        .example-image img {
            width: 100%;
            height: auto;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="sidebar">
            <div class="logo">
                <img src="{{ url_for('static', filename='img/favicon.svg') }}" alt="Logo">
                <h1>深绘智创</h1>
            </div>
            <button id="newChat" class="new-chat-btn">
                <i class="material-icons">add</i>新绘画
            </button>
            <div class="history-list">
                <h3>历史记录</h3>
                <ul id="historyItems">
                    <!-- 历史记录项将被动态添加 -->
                </ul>
            </div>
        </div>
        
        <div class="main-content">
            <div class="chat-header">
                <h2 class="chat-title">智慧绘画</h2>
                <button id="toggleParams" class="toggle-params-btn">
                    <i class="material-icons">settings</i>高级设置
                </button>
            </div>

            <!-- 生成参数面板 -->
            <div id="paramsPanel" class="params-panel">
                <h3>基本设置</h3>
                <div class="param-group">
                    <label for="width">宽度:</label>
                    <select id="width" name="width">
                        <option value="512">512px</option>
                        <option value="768">768px</option>
                        <option value="1024">1024px</option>
                    </select>
                    
                    <label for="height">高度:</label>
                    <select id="height" name="height">
                        <option value="512">512px</option>
                        <option value="768">768px</option>
                        <option value="1024">1024px</option>
                    </select>
                </div>

                <div class="param-group">
                    <label for="batch_size">生成数量:</label>
                    <select id="batch_size" name="batch_size">
                        <option value="1">1张</option>
                        <option value="2">2张</option>
                        <option value="4">4张</option>
                    </select>
                    
                    <label for="steps">生成步数:</label>
                    <select id="steps" name="steps">
                        <option value="20" selected>20步</option>
                        <option value="30">30步</option>
                        <option value="40">40步</option>
                    </select>
                </div>

                <div class="param-group">
                    <label for="guidance_scale">提示词引导强度:</label>
                    <input type="range" id="guidance_scale" name="guidance_scale" min="1" max="15" value="7" step="1">
                    <span id="guidance_scale_value">7</span>
                </div>

                <h3>高级设置</h3>
                <div class="param-group">
                    <label for="sampler_name">采样方法:</label>
                    <select id="sampler_name" name="sampler_name">
                        <option value="Euler">Euler</option>
                        <option value="Euler a" selected>Euler a</option>
                        <option value="DPM++ 2M Karras">DPM++ 2M Karras</option>
                        <option value="DPM++ SDE Karras">DPM++ SDE Karras</option>
                        <option value="Restart">Restart</option>
                    </select>
                </div>

                <div class="param-group">
                    <label for="model_checkpoint">模型选择:</label>
                    <select id="model_checkpoint" name="model_checkpoint">
                        <option value="anything-v5.safetensors">动漫</option>
                        <option value="majicMIX realistic 麦橘写实_v7.safetensors">写实</option>
                    </select>
                </div>

                <div class="param-group">
                    <input type="checkbox" id="enable_hr" name="enable_hr" checked>
                    <label for="enable_hr">启用超分辨率 (2倍)</label>
                </div>
            </div>

            <div id="chatArea" class="chat-area">
                <!-- 添加加载动画 -->
                <div class="loading-chat">
                    <div class="loading-spinner"></div>
                    <p>加载绘画历史...</p>
                </div>
            </div>
            
            <div class="input-area draw-input-area">
                <textarea id="userInput" placeholder="描述您想要生成的图片..." rows="2"></textarea>
                <button id="sendBtn" class="send-btn">
                    <i class="material-icons">brush</i>
                </button>
            </div>
        </div>
    </div>

    <!-- 图片预览模态框 -->
    <div id="imageModal" class="modal">
        <div class="modal-content">
            <span class="close-modal">&times;</span>
            <img id="modalImage" src="" alt="预览图片">
            <button id="downloadBtn" class="download-btn">下载图片</button>
        </div>
    </div>

    <script src="https://cdn.socket.io/4.4.1/socket.io.min.js"></script>
    <script>
        // 将会话ID传递给JavaScript
        const sessionId = "{{ session_id }}";
        const initialMode = "draw";
    </script>
    <script src="{{ url_for('static', filename='js/api.js') }}"></script>
    <script src="{{ url_for('static', filename='js/chat.js') }}"></script>
    <script src="{{ url_for('static', filename='js/draw.js') }}"></script>
    <script src="{{ url_for('static', filename='js/history.js') }}"></script>
    <script src="{{ url_for('static', filename='js/sidebar.js') }}"></script>
</body>
</html> 